<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="币种" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
              <a-input v-model="model.bz" placeholder="请输入币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="去年同期余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qntqye">
              <a-input-number v-model="model.qntqye" placeholder="请输入去年同期余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上月发生额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="syfs">
              <a-input-number v-model="model.syfs" placeholder="请输入上月发生额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="去年同期发生" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qntqfs">
              <a-input-number v-model="model.qntqfs" placeholder="请输入去年同期发生" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上月加权平均利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="syll">
              <a-input-number v-model="model.syll" placeholder="请输入上月加权平均利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上月余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="syye">
              <a-input-number v-model="model.syye" placeholder="请输入上月余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="去年同期加权平均利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qntqll">
              <a-input-number v-model="model.qntqll" placeholder="请输入去年同期加权平均利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="产品类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cplx">
              <j-tree-select
                ref="treeSelect"
                placeholder="请选择产品类型"
                v-model="model.cplx"
                dict="llbb_param_config,name,code"
                pidValue="1486540209969999874"
                hasChildField="has_child"
              >
              </j-tree-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="产品期限类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ckqxlx">
              <a-input v-model="model.ckqxlx" placeholder="请输入产品期限类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="存款类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cklx">
              <a-input v-model="model.cklx" placeholder="请输入存款类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="当月余额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dyye">
              <a-input-number v-model="model.dyye" placeholder="请输入当月余额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="余额同比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yetb">
              <a-input-number v-model="model.yetb" placeholder="请输入余额同比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="余额环比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yehb">
              <a-input-number v-model="model.yehb" placeholder="请输入余额环比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="当月发生额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dyfs">
              <a-input-number v-model="model.dyfs" placeholder="请输入当月发生额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发生额同比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fstb">
              <a-input-number v-model="model.fstb" placeholder="请输入发生额同比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发生额环比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fshb">
              <a-input-number v-model="model.fshb" placeholder="请输入发生额环比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="当月加权平均利率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dyjqpjll">
              <a-input-number v-model="model.dyjqpjll" placeholder="请输入当月加权平均利率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="同比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tb">
              <a-input-number v-model="model.tb" placeholder="请输入同比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="环比" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hb">
              <a-input-number v-model="model.hb" placeholder="请输入环比" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="当月最高利率（%）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dyzgll">
              <a-input-number v-model="model.dyzgll" placeholder="请输入当月最高利率（%）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjrq">
              <j-date placeholder="请选择数据日期" v-model="model.sjrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'LlbbDepositLlForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/reportInfo/llbbDepositLl/add",
          edit: "/reportInfo/llbbDepositLl/edit",
          queryById: "/reportInfo/llbbDepositLl/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>